/*	@brief Store 4 float. Thoses float can be used for representing vertex 
 * 	position, colors or other attributes
 */
Vec4	=	function (x,y,z,w)
{
	/********************************
	/*			Properties			
	/********************************/
	
		this.x=0;
		this.y=0;
		this.z=0;
		this.w=0;
	
	/********************************
	/*			Constructors		
	/********************************/
	
	if(x !=undefined)
	{
		this.x=x;
		this.y=y;
		this.z=z;
		this.w=w;
	}
}

	/********************************
	 *			Methods				
	 ********************************/

		Vec4.prototype.Minus = function( v)
		{
			 var temp = new Vec4();
			
			temp.x= this.x 	- v.x;
			temp.y= this.y 	- v.y;
			temp.z= this.z 	- v.z;
			temp.w= 1;
			
			return temp;
		}
			
		Vec4.prototype.Plus = function( v)
		{
			var 	temp = new Vec4();
		
			temp.x= this.x 	+ v.x;
			temp.y= this.y 	+ v.y;
			temp.z= this.z 	+ v.z;
			temp.w= 1;
			
			return temp;
		}
		
		
		Vec4.prototype.MultScalaire = function( v)
		{
			var 	temp = new Vec4();
			
			temp.x= this.x 	* v;
			temp.y= this.y 	* v;
			temp.z= this.z 	* v;
			temp.w= 1;
			
			return temp;
		}
		
		Vec4.prototype.Length = function()
		{
			 var sum=0;

				sum+=Math.pow(this.x,2);
				sum+=Math.pow(this.y,2);
				sum+=Math.pow(this.z,2);
				sum+=Math.pow(this.w,2);

			return Math.sqrt(sum);
		}
		
		Vec4.prototype.Normalize = function()
		{
			var length = this.Length();

			var out ;

			if(length==0)
			{
				out= new Vec4(0.0, 0.0, 0.0);
			}
			else
			{
				out= new Vec4(this.x/length, this.y/length, this.z/length);
			}

			return out;

		}
	/********************************/
	/*			Static				*/
	/********************************/
	
		/********************************/
		/*			Properties			*/
		/********************************/
		
			/*! Shortcut to recurrent vector values	*/
			Vec4.Default = new Vec4(1,1,1,1);	
			
		/********************************/
		/*			Methods				*/
		/********************************/
			
			Vec4.Minus = function( u,  v)
			{
				vec = new Vec4();
				
				vec.x= u.x - v.x;
				vec.y= u.y - v.y;
				vec.z= u.z - v.z;
				vec.w= 1;
				return vec;
			}
			
			Vec4.Plus = function( u,  v)
			{
				vec = new Vec4();
				
				vec.x= u.x + v.x;
				vec.y= u.y + v.y;
				vec.z= u.z + v.z;
				vec.w= 1;
				return vec;
			}
			
			Vec4.MultScalaire = function( u,  v)
			{
				vec = new Vec4();
				
				vec.x= u.x * v;
				vec.y= u.y * v;
				vec.z= u.z * v;
				vec.w= 1;
				return vec;
			}
			
			Vec4.Dot = function( u,  v)
			{
				return ((u.x*v.x)+(u.y*v.y)+(u.z*v.z));
			}

			Vec4.Cross = function( u,  v)
			{
				var tempVector= new Vec4(0.0,0.0,0.0, 1.0);

				tempVector.x=  (u.y*v.z)-(v.y*u.z);
				tempVector.y=  (u.z*v.x)-(v.z*u.x);
				tempVector.z=  (u.x*v.y)-(v.x*u.y);

				return tempVector;
			}
